/*----------------------------------------------------------------------------
 * CMSIS-RTOS 'main' function template
 *---------------------------------------------------------------------------*/

#define osObjectsPublic                     // define objects in main module
#include "osObjects.h"                      // RTOS object definitions


/*
 * main: initialize and start the system
 */
int main(void)
{
    /* STM32F2xx HAL library initialization:
         - Configure the Flash prefetch, Flash preread and Buffer caches
         - Systick timer is configured by default as source of time base, but user
               can eventually implement his proper time base source (a general purpose
               timer for example or other time source), keeping in mind that Time base
               duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
               handled in milliseconds basis.
         - Low Level Initialization
       */
    HAL_Init();

    /* Configure the system clock to 120 MHz */
    SystemClock_Config();
    SystemCoreClockUpdate();
    osKernelInitialize();                     // initialize CMSIS-RTOS


    // initialize peripherals here
    stdout_init();
    LED_Initialize();
    LED_Off(0);
    LED_Off(1);
    LED_Off(2);
    LED_Off(3);

    // create 'thread' functions that start executing,
    // example: tid_name = osThreadCreate (osThread(name), NULL);

    Init_Thread();

    osKernelStart();                          // start thread execution
    while (1)
    {
        LED_On(3);
        osDelay(200);
        LED_Off(3);
        osDelay(800);
    }
}
